<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>添加属性</button>
</body>
<script>
  //函数
    // function People(like,lang) {
    //     console.log(this)
    //     this.name = '张三'
    //     this.age = 10;
    //     this.sex = '男'
    //     this.like = like;
    //     this.yuyan = lang
    // }
    // console.log(   People.prototype)
    // People.prototype.say =function(){
    //     console.log("学习使我快乐")
    // }
    // People.prototype.push = ()=>{
    //     console.log("添加")
    // }
    // let p = new People("学习","日语");
    // let p1 = new People("打游戏",'俄罗斯语')
    // console.log(p)
    // console.log(p1)

     // 1，定义class类  静态属性
    class People{
        name="张三";
        age=18;
        sex = '男';
        // 固定属性 构造函数
        constructor(like,lang){
            console.log(this)
        // 2，动态属性
            this.like = like
            this.yuyan = lang
            console.log("构造函数")
        }
        // 3， 原型属性
        say(){
            console.log("学习使我快乐")
            console.log(this)
            this.push();
        }
        push(){
            console.log("添加")
        }
        //4， 定义 类属性   用static
        static lzq = "李志琦"
    }
    let p = new People("学习",'日语');
    let p1 = new People("打游戏","俄罗斯语")
    console.log(p)
    console.log(p1)
    p.say();

    //类属性只能使用class类调用
    console.log(People.lzq)
    // let obj = {};
    // obj.age =  '张少彭';
    // obj.sex = '男'
    // obj.sex = '女'
    // console.log(obj["age"])
</script>

</html>